load-pkg
![Build Status](https://img.shields.io/travis/jonschlinkert/load-pkg.svg)
Loads the package.json from the root of the user's current project.
HEADS UP!
Breaking changes in v2.0. The main export is now a function that must be called. This is so that the package.json is lazily loaded when the function is called.
Install
Install with npm
$ npm i load-pkg --save
async usage
var loadPkg = require('load-pkg');
loadPkg(function(err, pkg) {
console.log(pkg.name);
});
loadPkg('~/foo/bar', function(err, pkg) {
console.log(pkg.name);
});
sync usage
var pkg = require('load-pkg').sync(process.cwd());
console.log(pkg.name);
Specify the cwd or filepath to start from:
var pkg = require('load-pkg').sync('a/b/c');
console.log(pkg.name);
Related projects
- cwd: Easily get the CWD (current working directory) of a project based on package.json, optionally starting… more | homepage
- find-pkg: Find the first directory with a package.json, recursing up, starting with the given directory. | homepage
- look-up: Faster drop-in replacement for find-up and findup-sync. | homepage
Running tests
Install dev dependencies:
$ npm i -d && npm test
Contributing
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Author
Brian Woodward
License
Copyright © 2015 Brian Woodward
Released under the MIT license.
This file was generated by verb on December 13, 2015.